<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        
        var arr = [{ name: '张三'},{age: 18}]; //对象数组
        // var arr = [1, 34, 67, 89]; // [1,34,67,89]  
        // var arr = {name: '王俊凯', age: 20} //{"name":"王俊凯","age":20}
        var jsonStr = JSON.stringify(arr);
        console.log(jsonStr);
        //json字符串
        // var jsonStr1 = '{"name": "李四", "age": 18}'
        var jsonStr1 = '["张安", "李四", "王五"]';
        // jsonStr1 += 1; //会报错
        // JSON.parse : 转换的一定是一个纯的json数据
        var obj = JSON.parse(jsonStr1);
        console.log(obj);
    </script>
</body>
</html>